// user.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { Prisma, user } from '@prisma/client';
import { AuthingService } from '../authing/authing.service';

@Injectable()
export class UserService {
  constructor(
    private prisma: PrismaService,
    private authingService: AuthingService
  ) {}
  async getUsers(): Promise<user[]> {
    return this.prisma.user.findMany();
  }
  async setUsers(userData: Prisma.userCreateInput) {
    const user =await this.prisma.user.findFirst({
      where:{
        mobile:userData.mobile
      }
    })
    if(user){
    return  this.prisma.user.update({
        where:{
          id:user.id
        },
        data:userData
      })
    }
    return  this.prisma.user.create({ data: userData });
  }
}
